a="hello \nworld!"
print(a)
print(a*2)

b="go to hell"
print(b,end="\t")
print(b,end="\t")


'''
字符串是不变的,immutable
'''
a="sfsfsfsfs"
b=a.replace('s','t')
print(a,b)
#a[0]='33'


'''
切片, start和end偏移量超过范围，不报错
'''
a = "abcd"
print(a, a[::-1], a[-100:100])

'''
字符拼接，+会每加一次，新增一个对象；多次拼接建议用join+append,只一次新对象一次join
'''
import time
time1 = time.time()
a = ""
for i in range(1000000):
    a += "sxt"
time2 = time.time()
print(f'+号拼接时间：{str(time2-time1)}')

time3 = time.time()
li = []
for i in range(1000000):
    li.append("sxt")
b = "".join(li)
time4 = time.time()
print(f"join拼接时间：{str(time4-time3)}")



'''
mutable
'''
import io
a = 'heloo world'
a_io = io.StringIO(a)
print(a_io.getvalue())
a_io.seek(3)
a_io.write('333')
print(a_io.getvalue())
